import Axios from '@/utils/request';
import { Dictionary } from '@/pages/risk-time/types/Dictionary';

/**
 * 获取期货的合约乘数
 */
export function getFutureContractMulti(stockCode): Promise<any> {
    return Axios.get('/dict/query/contractMulti/' + stockCode);
}

/**
 * 查询未来150天的交易日期
 */
export function getSystemTradeDay(): Promise<any> {
    return Axios.get('/baseInfomation/system/trade/day');
}

export function getBankSelect(data) {
    return Axios.post('/dict/bank/select', data);
}

export function getStockReportSelect(type, data) {
    return Axios.post('/dict/stock/report/select/' + type, data);
}

/**
 * 字段说明信息
 */
export function getColumnComment(tableName): Promise<any> {
    return Axios.post('/original/column/comment/byName', tableName);
}

/**
 * 查找证券是否存在
 */
export function foundStockExistAsync(data) {
    return Axios({
        url: '/dict/stock/exist',
        method: 'post',
        data: data,
    });
}

export function getBusinessType(marketCode, stockType): Promise<Dictionary[]> {
    // return Axios.get('/dict/businessType/' + marketCode + '/' + stockType);
    return Axios.post('/dict/businessType', { marketCode, stockType });
}

export function getCNYExRateByCodeAsync(stockCode): Promise<any> {
    return Axios.get('/dict/query/stock/CNYExRate/' + stockCode);
}

/**
 * 查询产品实时持仓
 * @param data {businessType}:1-交易所业务,2-银行间债券,4-期货指令,I-上交所固定收益平台,E-交易所大宗交易,A-开放式基金
 */
export function getFundPosition(data: any): Promise<any> {
    return Axios.post('/position/stock', data);
}

/**
 * 获取指令证券类别
 * @param type {type}: 1-交易所业务 2-银行间债券 3-银行间回购 4-上交所固收 5-交易所大宗 6-期货业务 7-开放式基金 8-网下申购 9-融资融券信用业务
 */
export function getStockType(type: string): Promise<any> {
    return Axios.get('/dict/instruction/stockType/' + type);
}

/**
 * 获取最小买卖单位
 * @param data
 * @returns
 */
export function getMinUnit(data: any): Promise<any> {
    return Axios.post('/dict/getMinLimited', data);
}
